jQuery(function(o) {
    getList();

    var r = !0;
    o(window).scroll(function() {
        // o(document).scrollTop() > o(document).height() - 1e3 && !0 === r && getList()
        o(document).scrollTop()>=o(document).height()-o(window).height()-150 && !0 === r && getList()
    })

    function getList(){
        var e = {
            page: loadmore_params.current_page,
            page_size: loadmore_params.page_size
        };
        o.ajax({
            url: loadmore_params.ajaxurl,
            data: e,
            type: "POST",
            beforeSend: function(o) {
                r = !1
            },
            success: function(res) {
                var e=""
                for (var i = 0; i < res.data.data.length; i++) {
                    const element = res.data.data[i];
                    e +='<div class="portfoliogrid__item portfoliogrid__item--'+ element.id +' still-image-creation">'+
                            '<article class="projectcard post-'+ element.id +' portfolio type-portfolio status-publish has-post-thumbnail hentry project-type-still-image-creation" style="margin: .625rem 0;">'+
                                '<header class="projectcard__header">'+
                                    '<figure class="projectcard__figure" style="padding-bottom: '+ (element.height/element.width)*100 +'%;margin:0;" itemscope>'+
                                      '<a href="javascript:void(0)" data-imagetarget="'+ element.path_m +'" data-size="'+ element.width +'x'+ element.height +'">'+
                                        '<img width="1920" height="'+ 1920*(element.height/element.width) +'" src="'+ element.path_m +'" class="attachment-medium size-medium wp-post-image" alt="" loading="lazy" sizes="(max-width: 1920px) 100vw, 1920px">'+
                                      '</a>'+
                                    '</figure>'+
                                    '<h2 class="projectcard__title" style="display:none;"></h2>'+
                                    '<p class="projectcard__quickinfo" style="display:none;"></p>'+
                                '</header>'+
                            '</article>'+
                        '</div>'
                }

                e && ($portfoliogrid.length && $portfoliogrid.isotope("insert", o(e)),
                $postgrid.length && $postgrid.isotope("insert", o(e)),
                r = !0,
                loadmore_params.current_page++)

                if(loadmore_params.current_page == 2){
                    getList();
                }
            }
        })
    }
});